﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class PDFExportParams : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public PDFExportParams(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(PDFExportParams obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~PDFExportParams()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_PDFExportParams(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		private static uint[] UnMarshalPalette(IntPtr p)
		{
			if (p == IntPtr.Zero)
			{
				return null;
			}
			uint[] array = new uint[256];
			for (int i = 0; i < 256; i++)
			{
				array[i] = (uint)Marshal.ReadInt32(p, i * 4);
			}
			return array;
		}

		private static IntPtr MarshalPalette(uint[] p)
		{
			if (p == null)
			{
				return IntPtr.Zero;
			}
			if (p.Length != 256)
			{
				throw new Exception("MarshalPalette: palette size must be 256");
			}
			IntPtr intPtr = Marshal.AllocCoTaskMem(1024);
			for (int i = 0; i < 256; i++)
			{
				Marshal.WriteInt32(intPtr, i * 4, (int)p[i]);
			}
			return intPtr;
		}

		public uint[] Palette
		{
			get
			{
				return PDFExportParams.UnMarshalPalette(GlobalsPINVOKE.PDFExportParams_getPalette(this.swigCPtr));
			}
			set
			{
				IntPtr intPtr = PDFExportParams.MarshalPalette(value);
				GlobalsPINVOKE.PDFExportParams_setPalette(this.swigCPtr, intPtr);
				Marshal.FreeCoTaskMem(intPtr);
			}
		}

		public PDFExportParams() : this(GlobalsPINVOKE.new_PDFExportParams(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setPRCMode(PDFExportParams.PRCSupport flags)
		{
			GlobalsPINVOKE.PDFExportParams_setPRCMode(this.swigCPtr, (int)flags);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.PRCSupport PRCMode()
		{
			PDFExportParams.PRCSupport result = (PDFExportParams.PRCSupport)GlobalsPINVOKE.PDFExportParams_PRCMode(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDatabase(OdRxObject pDb)
		{
			GlobalsPINVOKE.PDFExportParams_setDatabase(this.swigCPtr, OdRxObject.getCPtr(pDb));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdRxObject database()
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.PDFExportParams_database(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setVersion(PDFExportParams.PDFExportVersions version)
		{
			GlobalsPINVOKE.PDFExportParams_setVersion(this.swigCPtr, (int)version);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.PDFExportVersions version()
		{
			PDFExportParams.PDFExportVersions result = (PDFExportParams.PDFExportVersions)GlobalsPINVOKE.PDFExportParams_version(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setOutput(OdStreamBuf output)
		{
			GlobalsPINVOKE.PDFExportParams_setOutput(this.swigCPtr, OdStreamBuf.getCPtr(output));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdStreamBuf output()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.PDFExportParams_output(this.swigCPtr);
			OdStreamBuf result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdStreamBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdStreamBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdStreamBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setExportFlags(PDFExportParams.PDFExportFlags flags)
		{
			GlobalsPINVOKE.PDFExportParams_setExportFlags(this.swigCPtr, (int)flags);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.PDFExportFlags exportFlags()
		{
			PDFExportParams.PDFExportFlags result = (PDFExportParams.PDFExportFlags)GlobalsPINVOKE.PDFExportParams_exportFlags(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setSearchableTextType(PDFExportParams.SearchableTextType type)
		{
			GlobalsPINVOKE.PDFExportParams_setSearchableTextType(this.swigCPtr, (int)type);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.SearchableTextType searchableTextType()
		{
			PDFExportParams.SearchableTextType result = (PDFExportParams.SearchableTextType)GlobalsPINVOKE.PDFExportParams_searchableTextType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setColorPolicy(PDFExportParams.ColorPolicy policy)
		{
			GlobalsPINVOKE.PDFExportParams_setColorPolicy(this.swigCPtr, (int)policy);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.ColorPolicy colorPolicy()
		{
			PDFExportParams.ColorPolicy result = (PDFExportParams.ColorPolicy)GlobalsPINVOKE.PDFExportParams_colorPolicy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setLayouts(OdStringArray layouts)
		{
			GlobalsPINVOKE.PDFExportParams_setLayouts(this.swigCPtr, OdStringArray.getCPtr(layouts));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdStringArray layouts()
		{
			OdStringArray result = new OdStringArray(GlobalsPINVOKE.PDFExportParams_layouts(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setPageParams(OdGsPageParamsArray pageParams)
		{
			GlobalsPINVOKE.PDFExportParams_setPageParams(this.swigCPtr, OdGsPageParamsArray.getCPtr(pageParams));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsPageParamsArray pageParams()
		{
			OdGsPageParamsArray result = new OdGsPageParamsArray(GlobalsPINVOKE.PDFExportParams_pageParams(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setBackground(uint background)
		{
			GlobalsPINVOKE.PDFExportParams_setBackground(this.swigCPtr, background);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public uint background()
		{
			uint result = GlobalsPINVOKE.PDFExportParams_background(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setGeomDPI(ushort dpi)
		{
			GlobalsPINVOKE.PDFExportParams_setGeomDPI(this.swigCPtr, dpi);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public ushort getGeomDPI()
		{
			ushort result = GlobalsPINVOKE.PDFExportParams_getGeomDPI(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setHatchDPI(ushort dpi)
		{
			GlobalsPINVOKE.PDFExportParams_setHatchDPI(this.swigCPtr, dpi);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public ushort hatchDPI()
		{
			ushort result = GlobalsPINVOKE.PDFExportParams_hatchDPI(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setColorImagesDPI(ushort dpi)
		{
			GlobalsPINVOKE.PDFExportParams_setColorImagesDPI(this.swigCPtr, dpi);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public ushort colorImagesDPI()
		{
			ushort result = GlobalsPINVOKE.PDFExportParams_colorImagesDPI(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setBWImagesDPI(ushort dpi)
		{
			GlobalsPINVOKE.PDFExportParams_setBWImagesDPI(this.swigCPtr, dpi);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public ushort bwImagesDPI()
		{
			ushort result = GlobalsPINVOKE.PDFExportParams_bwImagesDPI(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setTitle(string sTitle)
		{
			GlobalsPINVOKE.PDFExportParams_setTitle(this.swigCPtr, sTitle);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public string title()
		{
			string result = GlobalsPINVOKE.PDFExportParams_title(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setAuthor(string sAuthor)
		{
			GlobalsPINVOKE.PDFExportParams_setAuthor(this.swigCPtr, sAuthor);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public string author()
		{
			string result = GlobalsPINVOKE.PDFExportParams_author(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setSubject(string sSubject)
		{
			GlobalsPINVOKE.PDFExportParams_setSubject(this.swigCPtr, sSubject);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public string subject()
		{
			string result = GlobalsPINVOKE.PDFExportParams_subject(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setKeywords(string sKeywords)
		{
			GlobalsPINVOKE.PDFExportParams_setKeywords(this.swigCPtr, sKeywords);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public string keywords()
		{
			string result = GlobalsPINVOKE.PDFExportParams_keywords(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCreator(string sCreator)
		{
			GlobalsPINVOKE.PDFExportParams_setCreator(this.swigCPtr, sCreator);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public string creator()
		{
			string result = GlobalsPINVOKE.PDFExportParams_creator(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setProducer(string sProducer)
		{
			GlobalsPINVOKE.PDFExportParams_setProducer(this.swigCPtr, sProducer);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public string producer()
		{
			string result = GlobalsPINVOKE.PDFExportParams_producer(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setTGSpecific(bool bAllViews, OdGiDefaultContext giContext)
		{
			GlobalsPINVOKE.PDFExportParams_setTGSpecific__SWIG_0(this.swigCPtr, bAllViews, OdGiDefaultContext.getCPtr(giContext));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void setTGSpecific(bool bAllViews)
		{
			GlobalsPINVOKE.PDFExportParams_setTGSpecific__SWIG_1(this.swigCPtr, bAllViews);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiDefaultContext giContext()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.PDFExportParams_giContext(this.swigCPtr);
			OdGiDefaultContext result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGiDefaultContext)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGiDefaultContext)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGiDefaultContext)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool allViews()
		{
			bool result = GlobalsPINVOKE.PDFExportParams_allViews(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setSolidHatchesExportType(PDFExportParams.ExportHatchesType type)
		{
			GlobalsPINVOKE.PDFExportParams_setSolidHatchesExportType(this.swigCPtr, (int)type);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.ExportHatchesType solidHatchesExportType()
		{
			PDFExportParams.ExportHatchesType result = (PDFExportParams.ExportHatchesType)GlobalsPINVOKE.PDFExportParams_solidHatchesExportType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setOtherHatchesExportType(PDFExportParams.ExportHatchesType type)
		{
			GlobalsPINVOKE.PDFExportParams_setOtherHatchesExportType(this.swigCPtr, (int)type);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public PDFExportParams.ExportHatchesType otherHatchesExportType()
		{
			PDFExportParams.ExportHatchesType result = (PDFExportParams.ExportHatchesType)GlobalsPINVOKE.PDFExportParams_otherHatchesExportType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public ushort m_reserved1
		{
			get
			{
				ushort result = GlobalsPINVOKE.PDFExportParams_m_reserved1_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.PDFExportParams_m_reserved1_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public ushort m_reserved2
		{
			get
			{
				ushort result = GlobalsPINVOKE.PDFExportParams_m_reserved2_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.PDFExportParams_m_reserved2_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public uint m_reserved3
		{
			get
			{
				uint result = GlobalsPINVOKE.PDFExportParams_m_reserved3_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.PDFExportParams_m_reserved3_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public uint m_reserved4
		{
			get
			{
				uint result = GlobalsPINVOKE.PDFExportParams_m_reserved4_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.PDFExportParams_m_reserved4_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		public enum PDFExportFlags
		{
			kZeroFlag,
			kEmbededTTF,
			kTTFTextAsGeometry,
			kSHXTextAsGeometry = 4,
			kSimpleGeomOptimization = 8,
			kEnableLayers = 16,
			kIncludeOffLayers = 32,
			kEmbededOptimizedTTF = 64,
			kUseHLR = 128,
			kFlateCompression = 256,
			kASCIIHexEncoding = 512,
			kExportHyperlinks = 1024,
			kSupportTransparency = 2048,
			kZoomToExtentsMode = 4096,
			kDefault = 4870
		}

		public enum PRCSupport
		{
			kDisabled,
			kAsBrep,
			kAsMesh
		}

		public enum ExportHatchesType
		{
			kBitmap,
			kDrawing,
			kPdfPaths
		}

		public enum SearchableTextType
		{
			kNoSearch,
			kSHX,
			kTTF
		}

		public enum ColorPolicy
		{
			kNoPolicy,
			kMono,
			kGrayscale
		}

		public enum PDFExportVersions
		{
			kPDFv1_0 = 10,
			kPDFv1_1,
			kPDFv1_2,
			kPDFv1_3,
			kPDFv1_4,
			kPDFv1_5,
			kPDFv1_6,
			kLast = 16
		}
	}
}
